import { UtilsService } from '@app/utils';
import { Body, Controller, Get, Param, ParseIntPipe, Post } from '@nestjs/common';
import { ChargingStationService } from './charging-station.service';

@Controller('chargingStation')
export class ChargingStationController {
    constructor(
        private readonly service:ChargingStationService,
        private utils:UtilsService,
    ){
        
    }

    @Post('near')
    async near(@Body() dto:{lng:number, lat:number, distance:number}) {
        const res = await this.service.near(dto.lng, dto.lat, dto.distance)
        return this.utils.successRes(res)
    }

    @Get('station/:id')
    async station(@Param('id', ParseIntPipe) id:number) {
        if(isNaN(id) || id <= 0) return
        const res = await this.service.station(id)
        return this.utils.successRes(res)
    }
}
